package com.stroke.core;

import org.apache.log4j.Logger;

/**
 * Author: Igor Bubelov
 * Date: 3/8/11 1:59 AM
 */
public abstract class CoreRunnable implements Runnable {
    protected double period;
    protected boolean paused;

    protected CoreRunnable(int unitsPerSecond) {
        period = 1000d / unitsPerSecond;
    }

    public boolean isPaused() {
        return paused;
    }

    public void pause() {
        paused = true;
    }

    public void resume() {
        paused = false;
    }

    protected void sleep(long time) {
        try {
            Thread.sleep(time);
        } catch (InterruptedException ex) {
            Logger.getLogger(getClass()).error("Thread was interrupted", ex);
        }
    }
}
